package com.atguigu.gmall.seckill.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.seckill.service.SeckillGoodsService;
import com.atguigu.gmall.seckill.util.DateUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * projectName: gmall
 *
 * @author: 陈鹏
 * time: 2022/10/17 19:56 星期一
 * description: 秒杀商品相关的控制层
 */
@RestController
@RequestMapping(value = "/goods/seckill")
public class SeckillGoodsController {

    @Resource
    private SeckillGoodsService seckillGoodsService;

    /**
     * 获取时间段
     * @return
     */
    @GetMapping("/getDateInfo")
    public Result getDateInfo(){
        return Result.ok(DateUtil.getDateMenus());
    };

    /**
     * 查询指定时间段的商品列表
     * @param time
     * @return
     */
    @GetMapping("/getSeckillGoodsList")
    public Result getSeckillGoodsList(String time){
        return Result.ok(seckillGoodsService.getSeckillGoodsList(time));
    }

    /**
     * 查询指定时间段的指定商品
     * @param goodsId
     * @param time
     * @return
     */
    @GetMapping("/getSeckillGoods")
    public Result getSeckillGoods(String goodsId,String time){
        return Result.ok(seckillGoodsService.getSeckillGoods(goodsId,time));
    };
}
